define(["common"], function() {
	var pd = window.parent.document;
	var temp = $("<div>").append($("table tr:gt(1)")).html();
	var version = null;
	
	$.getJSON(g_contextPath + "/version/get/json", function(data) {
		version = data.result;
		$("#tstoreName").html(version.storeName);
		require(["qrcode"], function() {
			$('#qrcode').qrcode({size:100,text: "http://m.51mxz.com/store/" + version.storeId});
		});
	});
	
	window.initPrint = function () {
		
		$("#serial").html($("#serialCode", pd).val());
		$("#datetime").html(new Date().format("yyyy-MM-dd hh:mm"));
		$("table tr:gt(1)").remove();
		$("[id^='goods_']", pd).each(function() {
			// storeGoodsId
			var id = $(this).attr("id").split("_")[1];
			var item = temp
			.replace(/\-\{name\}\-/g, $("#tname_" + id, pd).html())
			.replace(/\-\{price\}\-/g, $("#tprice_" + id, pd).html())
			.replace(/\-\{amount\}\-/g, $("#amount_" + id, pd).val())
			.replace(/\-\{cost\}\-/g, $("#cost_" + id, pd).val());
			$("table").append(item);
		});
		$("#tnum").html($("[id^='goods_']", pd).length);
		$("#tcost").html($("#totalMoney", pd).html());
		$("#treceived").html($("#received", pd).val());
		$("#treturned").html($("#returned", pd).val());
	};
});
